//搜索框图标hover效果
var SearchIcon = document.querySelector("#Page1Search");
SearchIcon.firstElementChild.onmouseover = function () {
  SearchIcon.firstElementChild.src = "../images/Page1_SearchIconFocus.png";
};
SearchIcon.firstElementChild.onmouseout = function () {
  SearchIcon.firstElementChild.src = "../images/Page1_SearchIconBlur.png";
};

//左侧导航下拉菜单
var LeftNavBtn = document.getElementsByClassName("BannerLeftNav");
for (var i = 0; i < LeftNavBtn.length - 1; i++) {
  LeftNavBtn[i].nextElementSibling.style.display = "flex";
  LeftNavBtn[i].onclick = function () {
    if (this.nextElementSibling.style.display == "none") {
      this.nextElementSibling.style.display = "flex";
      this.lastElementChild.firstElementChild.style.transform =
        "rotate(180deg)";
    } else {
      this.nextElementSibling.style.display = "none";
      this.lastElementChild.firstElementChild.style.transform = "rotate(90deg)";
    }
  };
}

$("#GotoZZGL").click(function () {
  location.href = "./Employment_confirmation_management.html";
});

//查看红点消息界面的弹出
var SelfNews = document.querySelector("#NewsImg");
var SelfNewsShow = document.querySelector("#SelfNewsShow");
var MaskLayer = document.getElementById("MaskLayer");
var SelfNewsClose = document.getElementById("SelfNewsClose");
var NewsShowTimer;
var NewsHideTimer;
SelfNews.onclick = function () {
  clearTimeout(NewsHideTimer);
  SelfNewsShow.style.display = "flex";
  MaskLayer.style.display = "block";
  NewsShowTimer = setTimeout(NewsShow, 4);
};
MaskLayer.onclick = function () {
  clearTimeout(NewsShowTimer);
  SelfNewsShow.style.right = "-500px";
  MaskLayer.style.display = "none";
  NewsHideTimer = setTimeout(NewsHide, 200);
};
SelfNewsClose.onclick = function () {
  SelfNewsShow.style.right = "-500px";
  MaskLayer.style.display = "none";
  NewsHideTimer = setTimeout(NewsHide, 200);
};
function NewsShow() {
  SelfNewsShow.style.right = 0;
}
function NewsHide() {
  SelfNewsShow.style.display = "none";
}

//个人信息点击设置登录
var SelfSet = $("#SelfSetBox");
var SelfLoginSetBox = $("#SelfLoginSetBox");
SelfSet.click(function () {
  SelfLoginSetBox.slideToggle(200);
});

//应用中心选项按钮框
var AppBtn = document.getElementById("Page1AppIcon");
var AppShow = document.getElementById("AppShow");
var AppShowBox = document.getElementById("AppShowBox");
var AppShowHideTimer;
var AppShowShowTimer;
AppShowBox.style.top = "-400px";
AppBtn.onclick = function () {
  if (AppShowBox.style.top == "-400px") {
    clearTimeout(AppShowHideTimer);
    AppShowShowTimer = setTimeout(AppShowShow, 4);
    AppShow.style.display = "flex";
  } else {
    clearTimeout(AppShowShow);
    AppShowBox.style.top = "-400px";
    AppShowHideTimer = setTimeout(AppShowHide, 100);
  }
};
function AppShowHide() {
  AppShow.style.display = "none";
}
function AppShowShow() {
  AppShowBox.style.top = "3px";
}

//banner图标hover效果
var BannerSearch = document.querySelector("#BannerSearch");
BannerSearch.lastElementChild.onmouseover = function () {
  this.src = "../images/Page1_SearchIconFocus.png";
};
BannerSearch.lastElementChild.onmouseout = function () {
  this.src = "../images/Page1_BannerSearch.png";
};

var BannerUp = document.querySelectorAll(".BannerUp");
var BannerDown = document.querySelectorAll(".BannerDown");
BannerUp[0].onmousedown = function () {
  this.src = "../images/Page1_BannerTableUpArrowFocus.png";
};
BannerUp[0].onmouseup = function () {
  this.src = "../images/Page1_BannerTableUpArrow.png";
};
BannerUp[1].onmousedown = function () {
  this.src = "../images/Page1_BannerTableUpArrowFocus.png";
};
BannerUp[1].onmouseup = function () {
  this.src = "../images/Page1_BannerTableUpArrow.png";
};
BannerDown[0].onmousedown = function () {
  this.src = "../images/Page1_BannerTableUpArrowFocus.png";
};
BannerDown[0].onmouseup = function () {
  this.src = "../images/Page1_BannerTableUpArrow.png";
};
BannerDown[1].onmousedown = function () {
  this.src = "../images/Page1_BannerTableUpArrowFocus.png";
};
BannerDown[1].onmouseup = function () {
  this.src = "../images/Page1_BannerTableUpArrow.png";
};

var StuffDataArr = [
  {
    id: "11111111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "22222222222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "33333333333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "333",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "444444444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "444",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555555555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "555",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "666666666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "666",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "7777777777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "777",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "8888888888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "888",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "9999999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "999",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "100001000100",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "00000",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1101101110110",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "11111",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "120120120120",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222222",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1300013000130",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "333333333",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1400014444414",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "444444444",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1515151515151515",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "555555",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1666116166666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "6666666",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1717171777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "77777777",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1818181818",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "888888888",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "1919199919191",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "9999999",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "2020200202020",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "95",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "222111111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "44",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "222022220222222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "23",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "2233332222233333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "32",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "22444242424444222444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "33",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "2255225555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "21",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "22662222666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "241",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "2222777777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "114",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "2222888888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "14",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "22999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "333",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "333300000",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "333311111111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临11",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "33333322222222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "3333303333033333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "1111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "3333444444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "1111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "33335555555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "3333666666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "3333777777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "10000",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "333388888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "10",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "33333999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "10101000",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "4444400",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "2435",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "44411",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "52",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "444222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "12345",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "44443333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "5434",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "4440444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "64",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "44455555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "31",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "44466666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "14",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "444477777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "33",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "44888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "4449999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555550000",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555511111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555552222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "5555533333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "55544444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555555055",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "555566666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "55557777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "5555888888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "55559999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "66666000000060",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "6666111111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "666622222222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "66664444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "112",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "666655555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "222",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "66-666666666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "13131",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "666677777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "13313",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "6666888888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "122",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "6666999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "111",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "7777700000070",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "4444",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "7777111111",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "777",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777722222",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "727",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777733333",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "1324",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777744444",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "123",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777755555",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "123",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777766666",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "123",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "7777777-777",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "12233",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "777888888",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "23",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
  {
    id: "77779999999",
    name: "办公用品日常盘点",
    state: "未完成",
    dueDate: "2022-9-9",
    finishDate: "-",
    amount: "24",
    creator: "郭冬临",
    createDate: "2022-03-16 13:30:14",
  },
];

var page = 1;
var count = 8;
var StuffTable = document.querySelector("tbody");
var oPage = document.querySelector(".pagination");
//下面是搜索功能····························
var BannerSearchBtn = BannerSearch.lastElementChild;
var str = "";
BannerSearchBtn.onclick = function () {
  str = BannerSearch.firstElementChild.value;
  page = 1;
  render();
};
var data = [];
var tempArr = [];
var FirstPageNum = 1;
render();
function render() {
  //给所有数据加上编号
  for (var i = 0; i < StuffDataArr.length; i++) {
    var num = i;
    for (var key in StuffDataArr[i]) {
      StuffDataArr[i].constantNum = num + "";
    }
  }
  //先渲染搜索的功能
  data = [];
  tempArr = [];
  if (str.trim() == "") {
    data = StuffDataArr;
  } else {
    StuffDataArr.filter(function (json) {
      for (var key in json) {
        if (json[key].includes(str)) {
          data.push(json);
        }
      }
    });
    tempArr = [];
    for (var i = 0; i < data.length; i++) {
      if (tempArr.indexOf(data[i]) == -1) {
        tempArr.push(data[i]);
      }
    } //搜索结果去重
    data = tempArr;
  }

  //下面渲染页面数据
  StuffTable.innerHTML = "";
  var renderArr = data.slice((page - 1) * count, page * count);
  if (data.length == 0) {
    StuffTable.previousElementSibling.innerHTML = `<h1 style="width:100%;text-align:center;">未搜索到符合条件的结果！</h1>`;
    StuffTable.innerHTML = "";
    oPage.innerHTML = "";
  } else {
    StuffTable.previousElementSibling.innerHTML = `<td><input type="checkbox" class="CheckBox"/></td>
    <td>
      <div class="TableSpec">
        盘点单号
        <div>
          <img
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerUp"
          />
          <img
            style="transform: rotate(180deg); margin-top: 2px"
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerDown"
          />
        </div>
      </div>
    </td>
    <td>盘点名称</td>
    <td>盘点状态</td>
    <td>
      <div class="TableSpec">
        预计完成日期
        <div>
          <img
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerUp"
          />
          <img
            style="transform: rotate(180deg); margin-top: 2px"
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerDown"
          />
        </div>
      </div>
    </td>
    <td>
      <div class="TableSpec">
        实际完成日期
        <div>
          <img
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerUp"
          />
          <img
            style="transform: rotate(180deg); margin-top: 2px"
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerDown"
          />
        </div>
      </div>
    </td>
    <td>
      <div class="TableSpec">
        资产数量
        <div>
          <img
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerUp"
          />
          <img
            style="transform: rotate(180deg); margin-top: 2px"
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerDown"
          />
        </div>
      </div>
    </td>
    <td>创建人</td>
    <td>
      <div class="TableSpec">
        创建时间
        <div>
          <img
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerUp"
          />
          <img
            style="transform: rotate(180deg); margin-top: 2px"
            src="../images/Page1_BannerTableUpArrow.png"
            class="BannerDown"
          />
        </div>
      </div>
    </td>
    <td>操作</td>`;

    oPage.innerHTML = `<li id="PrePage">
    <a>
      <span>&laquo;</span>
    </a>
    </li>
    <li class="active"><a class="PageBtn">1</a></li>
    <li id="NextPage">
    <a>
      <span>&raquo;</span>
    </a>
    </li>`;
    for (var i = 0; i < renderArr.length; i++) {
      var oTr = document.createElement("tr");
      oTr.innerHTML = `
    <td><input type="checkbox" class="CheckBox"/></td>
    <td><a class="BannerSets" href="#">${renderArr[i].id}</a></td>
    <td>${renderArr[i].name}</td>
    <td style="color: rgb(245, 47, 47)">${renderArr[i].state}</td>
    <td>${renderArr[i].dueDate}</td>
    <td>${renderArr[i].finishDate}</td>
    <td>${renderArr[i].amount}</td>
    <td>${renderArr[i].creator}</td>
    <td>${renderArr[i].createDate}</td>
    <td>
    <a class="BannerSets" href="#">下载报告</a>
    </td>
    `;
      StuffTable.appendChild(oTr);
    }
    //下面是多选框
    var CheckBox = document.querySelectorAll(".CheckBox");
    var CheckNum = 0;
    CheckBox[0].onclick = function () {
      if (CheckBox[0].checked) {
        for (var i = 1; i < CheckBox.length; i++) {
          CheckBox[i].checked = true;
        }
        CheckNum = CheckBox.length - 1;
      } else {
        for (var i = 1; i < CheckBox.length; i++) {
          CheckBox[i].checked = false;
        }
        CheckNum = 0;
      }
    };
    for (var i = 1; i < CheckBox.length; i++) {
      CheckBox[i].onclick = function () {
        if (this.checked) {
          CheckNum++;
        } else {
          CheckNum--;
        }
        if (CheckNum == CheckBox.length - 1) {
          CheckBox[0].checked = true;
        } else {
          CheckBox[0].checked = false;
        }
      };
    }

    //下面是渲染分页器
    var PrePage = document.getElementById("PrePage");
    var NextPage = document.getElementById("NextPage");
    var aPage = document.querySelectorAll(".PageBtn");
    for (var i = 0; i < aPage.length; i++) {
      oPage.removeChild(aPage[i].parentNode);
    }
    if (Math.ceil(data.length / count) <= 5) {
      for (var i = 0; i < Math.ceil(data.length / count); i++) {
        var oLi = document.createElement("li");
        oLi.innerHTML = `<a class="PageBtn">${i + 1}</a>`;
        oPage.insertBefore(oLi, oPage.lastElementChild);
      }
    } else {
      if (page < Math.ceil(data.length / count) - 3) {
        for (var i = 0; i < 3; i++) {
          var oLi = document.createElement("li");
          oLi.innerHTML = `<a class="PageBtn">${FirstPageNum + i}</a>`;
          oPage.insertBefore(oLi, oPage.lastElementChild);
        }
        var oLi = document.createElement("li");
        oLi.innerHTML = `<a class="PageBtn">···</a>`;
        oPage.insertBefore(oLi, oPage.lastElementChild);
        for (
          var i = Math.ceil(data.length / count) - 2;
          i < Math.ceil(data.length / count);
          i++
        ) {
          var oLi = document.createElement("li");
          oLi.innerHTML = `<a class="PageBtn">${i + 1}</a>`;
          oPage.insertBefore(oLi, oPage.lastElementChild);
        }
        aPage = document.querySelectorAll(".PageBtn");
      } else {
        for (
          var i = Math.ceil(data.length / count) - 5;
          i < Math.ceil(data.length / count);
          i++
        ) {
          var oLi = document.createElement("li");
          oLi.innerHTML = `<a class="PageBtn">${i + 1}</a>`;
          oPage.insertBefore(oLi, oPage.lastElementChild);
        }
      }
    }
    aPage = document.querySelectorAll(".PageBtn");
    for (var i = 0; i < aPage.length; i++) {
      if (aPage[i].innerText == page + "") {
        aPage[i].parentNode.classList.add("active");
      }
      if (aPage[i].innerText == "···") {
        aPage[i].parentNode.classList.add("disabled");
        aPage[i].parentNode.classList.add("Mid");
      }
    }
    //翻页功能禁用
    if (
      aPage[0].parentNode.className == "active" &&
      aPage[0].innerText == "1"
    ) {
      PrePage.classList.add("disabled");
    } else {
      PrePage.classList.remove("disabled");
    }
    if (
      aPage[aPage.length - 1].parentNode.className == "active" &&
      aPage[aPage.length - 1].innerText == Math.ceil(data.length / count) + ""
    ) {
      NextPage.classList.add("disabled");
    } else {
      NextPage.classList.remove("disabled");
    }

    //下面是分页器功能···························
    for (var i = 0; i < aPage.length; i++) {
      aPage[i].onclick = function () {
        if (event.target.innerText == "···") {
          return;
        } else {
          page = event.target.innerText;
          render();
        }
      };
    }
    PrePage.onclick = function () {
      if (page > 1) {
        page--;
      }
      render();
    };
    NextPage.onclick = function () {
      if (page < Math.ceil(data.length / count)) {
        page++;
      }
      render();
    };
    //中间页变化的功能
    var MidPage = oPage.querySelector(".Mid");
    if (MidPage && MidPage.previousElementSibling.className == "active") {
      for (var i = 0; i < 3; i++) {
        aPage[i].innerText++;
        if (aPage[i].innerText != page) {
          aPage[i].parentNode.classList.remove("active");
        } else {
          aPage[i].parentNode.className = "active";
        }
      }
    }
    // if (MidPage) {
    aPage = document.querySelectorAll(".PageBtn");
    FirstPageNum = parseInt(aPage[0].innerText);
    if (aPage[0].parentNode.className == "active" && aPage[0].innerText != 1) {
      FirstPageNum--;
      render();
    }
    // }
  }
}

//下面是职位和员工类型选择下拉框··········································
var BannerPositionMenu = $("#BannerPositionMenu");
var BannerPositionMenuBtn = BannerPositionMenu.prev();
BannerPositionMenuBtn.click(function () {
  BannerPositionMenu.slideToggle(200);
  BannerPositionMenu.css("display", "flex");
});
var PositionBtn = BannerPositionMenu.children();
PositionBtn.click(function () {
  BannerPositionMenuBtn.text($(this).text());
  BannerPositionMenu.slideToggle(200);
});

//···············增删改······························
var AddModal = $("#AddModal");
AddModal.click(function () {
  $(this).hide();
});

var regAddName = /^[\u4e00-\u9fa5]{2,6}$/;
var regAddId = /^GH[0-9]{6}$/;
var regAddTel = /^1[3-9]\d{9}$/;
var regAddJoinDate = /^20[0-2]\d\-[0-1]\d\-[0-3]\d$/;
var regAddProbation = /^[0-6]个月$/;
var regAddConfirmation = /^20[0-2]\d\-[0-1]\d\-[0-3]\d$/;
var AddMemberBtn = $("#BannerMainBtn button").eq(0);
var AddMemberShow = $("#BannerRightBox2");
var AddMemberHide = $("#BannerRightBox1");
var confirmAdd = $("#BannerOptionSubmit button").eq(0);
var cancelAdd = $("#BannerOptionSubmit button").eq(1);
AddMemberBtn.click(function () {
  AddMemberShow.show();
  AddMemberHide.hide();
});
cancelAdd.click(function () {
  AddMemberShow.hide();
  AddMemberHide.show();
});
confirmAdd.click(function () {
  var tempData = document
    .querySelector("#BannerMainCont")
    .querySelectorAll("input");
  var name = tempData[0].value;
  var dueDate = tempData[1].value;
  var amount = tempData[2].value;
  var creator = tempData[3].value;
  var tempAddJson = {
    id: "tj" + StuffDataArr.length,
    name: name,
    constantNum: StuffDataArr.length + "",
    state: "未完成",
    dueDate: dueDate,
    finishDate: "-",
    amount: amount,
    creator: creator,
    createDate: new Date().toLocaleString() + "",
  };
  StuffDataArr.push(tempAddJson);
  render();
  AddMemberShow.hide();
  AddMemberHide.show();
});

var EditMemberBtn = $("#BannerMainBtn button").eq(1);
var SuccessTimer;
EditMemberBtn.click(function () {
  clearTimeout(SuccessTimer);
  $("#Success").slideDown();
  SuccessTimer = setTimeout(SuccessFn, 2000);
  event.cancelBubble = true;
});
function SuccessFn() {
  $("#Success").slideUp();
}

var RemoveMemberBtn = $("#BannerMainBtn button").eq(2);
var RemoveMember = $("#RemoveMember");
var RemoveMemberNum = 0;
RemoveMemberBtn.click(function () {
  var RemoveObj = document.querySelector("tbody").querySelectorAll(".CheckBox");
  var RemoveObjNum = 0;
  for (var i = 0; i < RemoveObj.length; i++) {
    if (RemoveObj[i].checked == true) {
      RemoveObjNum++;
    }
  }
  if (RemoveObjNum == 0) {
    AddModal.show();
    AddModal.text("请先从表格中勾选要删除的对象！");
  } else {
    RemoveMemberNum = 0;
    for (var i = 0; i < RemoveObj.length; i++) {
      if (RemoveObj[i].checked == true) {
        RemoveMemberNum++;
      }
    }
    RemoveMember.fadeIn();
    RemoveMember.css("display", "flex");
    $("#RemoveShow").text("确认要删除这 " + RemoveMemberNum + " 项吗？");
    $("#confirmRemove").on("click", function () {
      for (var i = RemoveObj.length - 1; i >= 0; i--) {
        if (RemoveObj[i].checked == true) {
          StuffDataArr.splice(data[(page - 1) * count + i].constantNum, 1);
        }
      }
      page = 1;
      FirstPageNum = 1;
      RemoveMember.fadeOut();
      render();
      $("#confirmRemove").off("click");
    });
  }
});
$("#cancelRemove").on("click", function () {
  RemoveMember.fadeOut();
});
